local extension=Package("steam_sjx")
extension.extensionName="aaa_steam"

Fk:loadTranslationTable{
    ["steam_sjx"]="设选",
}
local U = require "packages/utility/utility"
--- 按组展示牌，并询问选择若干个牌组（用于清正等）
---@param room Room
---@param player ServerPlayer @ 询问角色
---@param listNames table<string> @ 牌组名的表
---@param listCards table<table<integer>> @ 牌组所含id表的表
---@param minNum integer @ 最小值
---@param maxNum integer @ 最大值
---@param skillName? string @ 技能名
---@param prompt? string @ 提示信息
---@param allowEmpty? boolean @ 是否可以选择空的牌组，默认不可
---@param cancelable? boolean @ 是否可以取消，默认可
---@param canopen boolean@ 是否名牌，默认是
---@return table<string> @ 返回选择的牌组的组名列表
local askForChooseCardList = function (room, player, listNames, listCards, minNum, maxNum, skillName, prompt, allowEmpty, cancelable,canopen)
  local choices = {}
  skillName = skillName or ""
  prompt = prompt or skillName
  if (allowEmpty == nil) then allowEmpty = false end
  if (cancelable == nil) then cancelable = true end
  local availableList = table.simpleClone(listNames)
  if not allowEmpty then
    for i = #listCards, 1, -1 do
      if #listCards[i] == 0 then
        table.remove(availableList, i)
      end
    end
  end
  -- set 'cancelable' to 'true' when the count of cardlist is out of range
  if not cancelable and #availableList < minNum then
    cancelable = true
  end
  local result = room:askForCustomDialog(
    player, skillName,
    "packages/aaa_steam/qml/ChooseCardListBox.qml",
    { listNames, listCards, minNum, maxNum, prompt, allowEmpty, cancelable,canopen }
  )
  if result ~= "" then
    choices = json.decode(result)
  elseif not cancelable and minNum > 0 then
    if #availableList > 0 then
      choices = table.random(availableList, minNum)
    end
  end
  return choices
end


local xuyou= General(extension, "steam__xuyou", "qun", 3)--许攸


local qingxi= fk.CreateActiveSkill{
    name = "steam__qingxi",
    anim_type = "support",
    card_num = 0,
    target_num = 1,
    prompt = "#steam__qingxi",
    can_use = function(self, player)
      return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 

    end,
    target_filter = function(self, to_select, selected)
        return #selected == 0 and to_select ~= Self.id
      end,
    on_use = function(self, room, effect)
      local player=room:getPlayerById(effect.from)
      local target=room:getPlayerById(effect.tos[1])
      local num = (#player:getAvailableEquipSlots() - #player:getCardIds("e") )-1
      player:drawCards(math.max(num,1),self.name)
      local card1,card2
      if #player:getCardIds("h")>3 then
        local max=#player:getCardIds("h")-2
        card1=room:askForCard(player,2,max,false,self.name,false,".","#steam__qingxi-ask")

      else
        card1=room:askForCard(player,1,2,false,self.name,false,".","#steam__qingxi-ask")

      end
      card2=table.filter(player:getCardIds("h"),function(cid) return not table.contains(card1,cid) end)
      local listCards={card1,card2}
      local choice = askForChooseCardList(room, target, {"第一组","第二组"}, listCards, 1, 1, self.name,
      "#steam__qingxi-dis", false, false,false)
      if choice=="第一组" then
        room:throwCard(card1,self.name,player,target)
      else
        room:throwCard(card2,self.name,player,target)
      end

      local cards = player:getCardIds("h")
      player:showCards(cards)
      local card_s=table.filter(cards,function(cid) return Fk:getCardById(cid).trueName=="slash" end)
      local card_j=table.filter(cards,function(cid) return Fk:getCardById(cid).name=="jink"end)
      if #card_s>=2 then
        room:damage{
          to =target,from = player,damage = 1,damageType = fk.FireDamage,skillName = self.name,
        }
    
      elseif #card_j>=2 then
        if (#target:getCardIds(player.Hand) + #target:getCardIds(player.Equip)) > 0 then
          local cards = room:askForCardsChosen(player, target, 1, 1, "he", self.name, "#steam__qingxi-choscard::"..target.id)
          local dummy = Fk:cloneCard("dilu")
          dummy:addSubcards(cards) --
          room:obtainCard(player.id, dummy, true, fk.ReasonPrey)
        else
          local dummy = Fk:cloneCard("dilu")
          dummy:addSubcards(target:getCardIds("he"))
          room:obtainCard(player.id, dummy, true, fk.ReasonPrey)
        end
      end
    end,
}


  local yiji = fk.CreateTriggerSkill{
    name = "steam__yiji",
    anim_type = "control",
    events = {fk.EventPhaseStart},
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(self) and target.phase == Player.Play and target == player and not player:isNude()
    end,
    on_cost = function(self, event, target, player, data)
      local success, dat = player.room:askForUseActiveSkill(player, "steam__yiji_active", "#steam__yiji-ask", true)
      if success then
        self.cost_data = dat
        return true
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local data=self.cost_data 
  
      room:throwCard(data.cards, self.name, player, player)
      local ids = room:getCardsFromPileByRule(""..data.interaction, 1, "discardPile")
      if #ids > 0 then
        room:obtainCard(player, ids[1], false, fk.ReasonJustMove)
      end


    end,
  }

  local yiji_active = fk.CreateActiveSkill{
    name = "steam__yiji_active",
    interaction = function(self)
      return UI.ComboBox { choices = {"slash","jink"} }
    end,
    card_num = 1,
    card_filter = function(self, to_select, selected)
      if #selected==0 then return true end
    end,
    on_use = function(self, room, effect)
      return true
    end,
  }
  Fk:addSkill(yiji_active)
  xuyou:addSkill(qingxi)
  xuyou:addSkill(yiji)
Fk:loadTranslationTable{
    ["steam__xuyou"]="许攸",
    ["#steam__xuyou"] = "毕方矫翼",
    ["designer:steam__xuyou"] = "伶伶",

    ["steam__qingxi"]="轻袭",
    [":steam__qingxi"]=[[出牌阶段限一次，你可以摸X张牌（X为你空余装备栏数-1且至少为1），然后将手牌分为两份(每份至少两张！)，令一名其他角色弃置其中一份，你展示另一份，
    若其中有至少两张：【杀】，你对其造成1点火焰伤害；【闪】，你获得其一张牌。]],

    ["#steam__qingxi"]="轻袭:你可以摸X张牌（X为你空余装备栏数-1，且至少为1），然后将手牌分为两份!令一名角色选择一份弃置",
    ["#steam__qingxi-ask"]="轻袭:请将你的手牌分为两份（这是第一份！第二份将会自动生成）",
    ["#steam__qingxi-dis"]="轻袭:选择许攸的一份手牌弃置！",
    ["#steam__qingxi-choscard"]="轻袭:请获得%dest 两张牌！",

    ["steam__yiji"]="易计",
    [":steam__yiji"]="出牌阶段开始时，你可以弃置一张牌，然后秘密从弃牌堆获得一张【杀】或【闪】。",
    ["#steam__yiji-ask"]="易计:你可以弃置一张牌，然后秘密从弃牌堆获得一张【杀】或【闪】。",
    ["steam__yiji_active"]="抉择",
    
}
local fangao= General(extension, "steam__fangao", "west", 3)--梵高

local kunanjintou = fk.CreateActiveSkill{
  name = "steam__kunanjintou",
  anim_type = "offensive",
  prompt = "#steam__kunanjintou",
  card_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) < 2
  end,
  card_filter = function(self, to_select, selected)
    return #selected == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)

    room:throwCard(effect.cards, self.name, player, player)
    local cards=player:getTableMark("@$steam__kunanjintou")

    table.insert(cards,effect.cards[1])
    local suits = {}
    local numbers = {}
    for _, cid in ipairs(cards) do
      table.insertIfNeed(suits, Fk:getCardById(cid).suit)
      table.insertIfNeed(numbers, Fk:getCardById(cid).number)
    end
    if #suits >= 4 then
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = self.name
      })
    else
      room:loseHp(player, 1,self.name)

    end
    if #numbers >= 8 then
      room:killPlayer{who = player.id}
    end
    room:setPlayerMark(player,"@$steam__kunanjintou",cards)
  end,
}

Fk:addPoxiMethod{
  name = "steam__niuquxingkong-ch",
  card_filter = function(to_select, selected, data)
    if #selected==0 then 
      return true 
    elseif #selected==1 then
      return Fk:getCardById(to_select).color~=Fk:getCardById(selected[1]).color
    end

  end,
  feasible = function(selected)
    return  #selected<=2
  end,
  prompt = function ()
    return "扭曲虚空:获得两张颜色不同的牌。"
  end,
}

local niuquxingkong= fk.CreateTriggerSkill{
  name = "steam__niuquxingkong",
  events = {fk.HpChanged},
  frequency = Skill.Compulsory,
  can_trigger = function(self, event, target, player, data)
    return target==player and player:hasSkill(self.name) and not player.dead and player:usedSkillTimes(self.name, Player.HistoryRound) < 1
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = room.alive_players
    local req = Request:new(targets, "AskForUseActiveSkill")
    req.focus_text ="扭曲星空正在冲击灵魂！！！"
    for _, p in ipairs(targets) do
      local n=math.min(#p:getCardIds("he"),2)
      local extraData = {
        num = n,
        min_num = n,
        include_equip = true,
        pattern = ".",
        reason = self.name,
      }
      local data = {"choose_cards_skill", "#askForreset", false, extraData }
      req:setData(p, data)
      req:setDefaultReply(p, table.random(p:getCardIds("he"), n))
    end
    req:ask()
    for _, p in ipairs(targets) do
      local result = req:getResult(p)
      local card={}
      if result ~= "" then
        if type(result) == "table" and result.card then
          --dbg()

          card= result.card.subcards
        else
     
          card = result
        end
      else

          card = result

      end
      if #card>0 then
        room:recastCard(card, p, self.name)
      end

    end
    local cards = {}
    room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
      for _, move in ipairs(e.data) do
        if move.toArea == Card.DiscardPile then
          for _, info in ipairs(move.moveInfo) do
            table.insertIfNeed(cards, info.cardId)
          end
        end
      end
    end, Player.HistoryTurn)
    cards = table.filter(cards, function (id)
      return table.contains(room.discard_pile, id)
    end)
    --local cards = table.filter(room.discard_pile, function(id) return true end)
    --local c = room:askForCardsChosen(player, player, 1, 1, {card_data = {{self.name, cards}}}, self.name)
    local get=room:askForPoxi(player,"steam__niuquxingkong-ch",{
      { self.name, cards},
    }, nil, true)
    room:obtainCard(player, get, false, fk.ReasonPrey)

  end,
}


fangao:addSkill(kunanjintou)
fangao:addSkill(niuquxingkong)
Fk:loadTranslationTable{
  ["steam__fangao"]="梵高",
  ["#steam__fangao"]="麦田风声",
  ["designer:steam__fangao"] = "伶伶",
  ["steam__kunanjintou"]="苦难尽头",
  ["@$steam__kunanjintou"]="苦难",
  [":steam__kunanjintou"]="出牌阶段限一次，你可以弃置一张牌，然后失去1点体力。若你以此法弃置的牌：花色达到四种，“失去”改为“回复”；点数达到八种，你死亡。",
  ["steam__niuquxingkong"]="扭曲星空",
  [":steam__niuquxingkong"]="当你每轮首次体力变化后，你可以令所有角色各重铸两张牌（不足全重铸，无牌不重铸），然后你获得本回合进入弃牌堆至多两张颜色不同的牌。",
  ["#askForreset"] = "请重铸两张牌！",
  ["#steam__niuquxingkong-ch"]="扭曲星空:获得两张颜色不同的牌。",
  ["#steam__kunanjintou"]="苦难尽头:你可以弃置一张牌，然后失去1点体力。",

}

local lukang= General(extension, "steam__lukang", "wu", 3)--陆抗

local zhuwei = fk.CreateActiveSkill{
  name = "steam__zhuwei",
  anim_type = "control",
  prompt="铸围：弃置一张杀和武器牌，或者弃置一张闪和防具牌以获得技能（先选基本牌！）",
  can_use = function(self, player)
    return not player:isKongcheng() 
  end,
  card_filter = function(self, to_select, selected)
    local card = Fk:getCardById(to_select)
    if #selected == 0 then
      -- 选第一张牌时,可以是杀或闪
      return (card.name == "slash" or card.name == "jink") and 
             not Self:prohibitDiscard(card)
    elseif #selected == 1 then
      local first = Fk:getCardById(selected[1])
      if first.name == "slash" then
        -- 第一张是杀,第二张要是武器
        return card.sub_type == Card.SubtypeWeapon and
               not Self:prohibitDiscard(card)
      elseif first.name == "jink" then
        -- 第一张是闪,第二张要是防具
        return card.sub_type == Card.SubtypeArmor and
               not Self:prohibitDiscard(card)
      end
    end
    return false
  end,
  card_num = 2,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local cards = effect.cards
    local first = Fk:getCardById(cards[1])
    local second = Fk:getCardById(cards[2])
    
    room:throwCard(cards, self.name, player, player)
    
    if first.name == "slash" then
      -- 获得武器牌的技能
      if second.equip_skill then
        room:handleAddLoseSkills(player, second.equip_skill.name, nil, true)
      end
    elseif first.name == "jink" then
      -- 获得防具牌的技能
      if second.equip_skill then
        room:handleAddLoseSkills(player, second.equip_skill.name, nil, true)
      end
    end
  end
}
lukang:addSkill(zhuwei)


local xieyang = fk.CreateTriggerSkill{
  name = "steam__xieyang",
  anim_type = "drawcard",
  events = {fk.AfterSkillEffect},
  can_trigger = function(self, event, target, player, data)
    return target and target == player and player:hasSkill(self.name) and 
           data.name ~= self.name and data.name ~= "#steam__xieyang_buff" and  target:hasSkill(data)
            and not data.cardSkill
            and ((data:isPlayerSkill(player) and data.visible) or data:isEquipmentSkill(player))
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, self.name, data)
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
}

local xieyang_buff = fk.CreateAttackRangeSkill{
  name = "#steam__xieyang_buff",
  correct_func = function(self, from, to)
    if from:hasSkill(self) then
      return  #table.filter(
        from.player_skills,
        function(skill) return (skill:isPlayerSkill(from) and skill.visible) or skill:isEquipmentSkill(from)end
      )
    end
  end,
}

local xieyang_maxcards = fk.CreateMaxCardsSkill{
  name = "#steam__xieyang_maxcards", 
  correct_func = function(self, player)
    if player:hasSkill(self) then
      return  #table.filter(
        player.player_skills,
        function(skill) return (skill:isPlayerSkill(player) and skill.visible) or skill:isEquipmentSkill(player)end
      )
    end
  end,
}


xieyang:addRelatedSkill(xieyang_buff)
xieyang:addRelatedSkill(xieyang_maxcards)

lukang:addSkill(xieyang)

Fk:loadTranslationTable{
    ["steam__xieyang"] = "颉颃",
  [":steam__xieyang"] = "此你发动你的其他技能后，你可摸一张牌。你的攻击范围和手牌上限+你的技能数。(装备技能也可触发此技能)",
  ["steam__xieyang_draw"] = "颉颃",
  ["#steam__xieyang_buff"] = "颉颃",
  ["#steam__xieyang_maxcards"] = "颉颃",
}
-- 添加技能翻译
Fk:loadTranslationTable{
  ["steam__lukang"]="陆抗",
  ["steam__zhuwei"] = "铸围",
  [":steam__zhuwei"] = "出牌阶段，你可弃置一张【杀】和一张武器牌，或一张【闪】和一张防具牌，以永久获得此装备牌的技能。",
}







local caoshuang= General(extension, "steam__caoshuang", "wei", 4)--曹爽



local zhuanshe = fk.CreateTriggerSkill{
  name = "steam__zhuanshe",
  anim_type = "offensive",
  events = {fk.EventPhaseStart},
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(self) and target.phase == Player.Play and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
      --local card = player.room:askForCard(player, 1, 1, false, self.name, true, ".", "#ev__waiqumoyan::"..data.to)
      local card = player.room:askForCard(player, 1, 1, false, self.name, true, ".", "#steam__zhuanshe::"..target.id)
      if #card > 0 then
        self.cost_data = card[1]
        return true
      end
    end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cid = self.cost_data
    player:showCards(cid)
    if player.dead then return end
    room:obtainCard(target.id, cid, true, fk.ReasonGive)
    local card=Fk:getCardById(cid)
    
    room:setPlayerMark(target, "@steam__zhuanshe",card.name)
    if card.type == Card.TypeBasic or card:isCommonTrick() then
      room:setPlayerMark(target, "steam__zhuanshe-turn",1)
    end
  end,
}

local zhuanshe_delay= fk.CreateTriggerSkill{
  name = "#steam__zhuanshe_delay",
  anim_type = "offensive",
  events = {fk.TargetSpecifying,fk.TurnEnd},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(self) then return false end
    
    if event == fk.TurnEnd then
      if target:getMark("@steam__zhuanshe")==0 then return end
      local name=target:getMark("@steam__zhuanshe")
      local room = player.room
      local play_ids = {}
      room.logic:getEventsOfScope(GameEvent.Phase, 1, function (e)
        if e.data[2] == Player.Play and e.end_id then
          table.insert(play_ids, {e.id, e.end_id})
        end
        return false
      end, Player.HistoryTurn)
      if #play_ids == 0 then return true end
      --检测
      local function PlayCheck (e)
        local in_play = false
        for _, ids in ipairs(play_ids) do
          if e.id > ids[1] and e.id < ids[2] then
            in_play = true
            break
          end
        end
        return in_play and e.data[1].from == target.id and e.data[1].card.name == name
      end
      room:setPlayerMark(target, "@steam__zhuanshe",0)
      return #room.logic:getEventsOfScope(GameEvent.UseCard, 2, PlayCheck, Player.HistoryTurn) == 0

    elseif event == fk.TargetSpecifying then
      if target:getMark("@steam__zhuanshe")~=0 then

        return target:getMark("@steam__zhuanshe") == data.card.name and target:getMark("steam__zhuanshe-turn") == 1
        and data.card:getMark("zhuanshe-inhand")==0
      end
    end
   

  end,
  on_cost = function(self, event, target, player, data)
      local room=player.room
    if event == fk.TargetSpecifying then
      if player.dead then return end
      local availableTargets = U.getUseExtraTargets(room, data, true, true)
      local num = 1
      if #availableTargets > 0 and num > 0 then
          local targets = room:askForChoosePlayers(player, availableTargets, 1, num,
           "#steam__zhuanshe-choose:::"..data.card:toLogString() .. ":" .. num, self.name, true)
           if #targets > 0 then
            self.cost_data = targets
            data.card:setMark("zhuanshe-inhand",1)
            return true
          end

      end
    elseif event == fk.TurnEnd then
      return player.room:askForSkillInvoke(player, self.name, data, "#steam__zhuanshe-dmg::" .. target.id)
    end
  end,
  on_use = function(self, event, target, player, data)
      local room = player.room
      if event == fk.TargetSpecifying then
          local targets = self.cost_data
          if #targets > 0 then
              table.forEach(targets, function(pid) AimGroup:addTargets(room, data, pid) end)
          end
      else
          room:damage{
              from = player,
              to = target,
              damage = 1,
              skillName = self.name,
          }

      end
  end
}


local weiqiu=fk.CreateTriggerSkill{
  name = "steam__weiqiu",
  anim_type = "special",
  frequency = Skill.Compulsory,
  events = {fk.PreHpRecover},
  can_trigger = function(self, event, target, player, data)

   return player:hasSkill(self) and player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
      player:drawCards(1,self.name)
      return true
  end,
}
zhuanshe:addRelatedSkill(zhuanshe_delay)
caoshuang:addSkill(zhuanshe)
caoshuang:addSkill(weiqiu)

Fk:loadTranslationTable{
  ["steam__caoshuang"]="曹爽",
  ["steam__zhuanshe"]="专摄",
  [":steam__zhuanshe"]=[[其他角色的出牌阶段开始时，你可以展示一张手牌并交给其。当其于本回合内使用与之名称相同的基本牌或普通锦囊牌时，
  你可以额外指定一名角色为目标(无距离限制)。当前回合结束后，若其于本回合内未使用与之名称相同的牌，你可以对其造成1点伤害。]],

  ["steam__weiqiu"]="危秋",
  [":steam__weiqiu"]="锁定技，当一名角色回复体力时，若你没有手牌，改为令你摸一张牌。",

  [ "#steam__zhuanshe"]="专摄：你可展示一张手牌并交给%dest",
  ["@steam__zhuanshe"]="专摄",
  ["#steam__zhuanshe-choose"] = "专摄：为此%arg额外指定至多%arg2个目标",
  ["#steam__zhuanshe-dmg"]="专摄：你可以对%dest造成1点伤害",
  ["#steam__zhuanshe_delay"]="专摄",
  
}

local zhugdan = General(extension, "steam__zhugdan", "wei", 4)--诸葛诞
Fk:addPoxiMethod{
  name = "steam__yicheng_recast",
  card_filter = function(to_select, selected, data)
    return #selected<4
  end,
  feasible = function(selected)
    return #selected == 4
  end,
  prompt = function ()
    return "#steam__yicheng_recast-ask"
  end
}
Fk:loadTranslationTable{
  ["#steam__yicheng_recast-ask"]="枙城：你可以重铸你与一名其他角色共4张牌",
  ["@steam__yicheng_recast"]="枙城",
}
local yicheng = fk.CreateActiveSkill{
  name = "steam__yicheng",
  anim_type = "support",
  prompt = "#steam__yicheng_recast-ask",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:getMark("steam__yicheng-turn")==0
  end,
  card_filter = function(self, to_select, selected)
    return false
  end,
  target_filter = function(self, to_select, selected)
    return #selected == 0 and to_select ~= Self.id
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    local target = room:getPlayerById(effect.tos[1])
    local player_hands = player:getCardIds("he")
    local target_hands = target:getCardIds("he")
    local extra_data = {}
    local visible_data = {}
    for _, id in ipairs(player_hands) do
      if not player:cardVisible(id) then
        visible_data[tostring(id)] = false
      end
    end
    for _, id in ipairs(target_hands) do
      if not player:cardVisible(id) then
        visible_data[tostring(id)] = false
      end
    end
    if next(visible_data) == nil then visible_data = nil end
    extra_data.visible_data = visible_data
    local cards = room:askForPoxi(player, "steam__yicheng_recast", {
      { player.general, player_hands },
      { target.general, target_hands },
    }, extra_data, true)
    local peach = table.find(cards, function(id)
      return Fk:getCardById(id).name == "peach"
    end)
    local slash=table.filter(cards,function(cid) return Fk:getCardById(cid).trueName=="slash" end)
    local mycards=table.filter(cards,function(cid) return table.contains(player_hands,cid) end)
    local othercards=table.filter(cards,function(cid) return table.contains(target_hands,cid) end)

    if peach then
      room:throwCard(mycards, self.name, player, player)
      room:throwCard(othercards, self.name, target, player)
    else
      room:recastCard(mycards, player, self.name)
      room:recastCard(othercards, target, self.name)
    end
    if #slash > 0 then
      room:obtainCard(player, slash, true, fk.ReasonGive)
      room:setPlayerMark(player, "steam__yicheng-turn",1)
      
    end
  end,
}
local yicheng_delay=fk.CreateTriggerSkill{
  name = "#steam__yicheng_delay",
  anim_type = "support",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and player:getMark("steam__yicheng-turn")==0
  end,
  on_cost = function(self, event, target, player, data)
    local success, dat =  player.room:askForUseActiveSkill(player, "steam__yicheng", "枙城", true,nil,false)
    if success and dat then
      self.cost_data = {cards = dat.cards, tos = dat.targets}
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
      local room = player.room
      room:notifySkillInvoked(player, "steam__yicheng", "support")
  end,
}

yicheng:addRelatedSkill(yicheng_delay)
zhugdan:addSkill(yicheng)

Fk:loadTranslationTable{
  ["steam__zhugdan"] = "诸葛诞",
  ["#steam__zhugdan"] = "枙梦难成",
  ["designer:steam__zhugdan"] = "Sonaly",
  ["#steam__yicheng_delay"]="枙城",
  ["steam__yicheng"] = "枙城",
  [":steam__yicheng"] = [[出牌阶段或一名角色濒死时，你可以重铸你与一名其他角色共4张牌；若重铸的牌：包括【桃】，改为弃置；包括【杀】，
  你获得之且本回合【枙城】失效。]],
}






--[[
毕方矫翼 许攸 3
轻袭：出牌阶段限一次，你可以摸X张牌（X为你空余装备栏数），然后将手牌分为两份，每份至少两张，令一名其他角色弃置其中一份，你展示另一份，若其中有至少两张：【杀】，你对其造成2点火焰伤害；【闪】，你获得其两张牌。
易计：出牌阶段开始时，你可以弃置一张牌，然后秘密从弃牌堆获得一张【杀】或【闪】。

麦田风声 梵高 3
苦难尽头：出牌阶段限一次，你可以弃置一张牌，然后失去1点体力。若你以此法弃置的牌：花色达到四种，“失去”改为“回复”；点数达到八种，你自杀。
扭曲星空：当你每轮首次失去体力、受到伤害、回复体力后，你可以令所有角色各重铸两张牌（不足全重铸，无牌不重铸），然后你获得中央区至多两张颜色不同的牌，每轮每种牌名限获得一次。

诸葛诞 魏 4体力 
枙城：出牌阶段或一名角色濒死时，你可以重铸你与一名其他角色共4张牌；若重铸的牌：包括【桃】，改为弃置；包括【杀】，你获得之且本回合“枙城”失效

--]]


return extension
